<template>
  <div class="list-bar pad-20">
    <el-table ref="multipleTable" :data="goodsList" @selection-change="handleSelectionChange" v-loading="listLoading"
              element-loading-text="加载中" style="width: 100%">
      <el-table-column label="基本信息">
        <template slot-scope="scope">
          <div class="flex v-align-c cursor-p">
            <label><img :src="scope.row.goodsImgUrl" class="user-avatar"></label>
            <div class="font-14 pad-l-10">
              <div>{{scope.row.title}}</div>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column width="250px" label="价格" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.priceType === 1">{{scope.row.price}}元</span>
          <span v-if="scope.row.priceType === 2">{{scope.row.minPrice}}元~{{scope.row.maxPrice}}元</span>
          <span v-if="scope.row.priceType === 3">
            <span>原价{{scope.row.originalPrice}}元</span><br/>
            <span>现价{{scope.row.nowPrice}}元</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="链接" align="center" prop="goodsMiniUrl"></el-table-column>
    </el-table>
    <!-- 列表分页 -->
    <div class="pagination">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchListQuery.currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="searchListQuery.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import { pageLiveRoomApplyGoods } from '@/api/user/liveRoomApplyGoods'
  import { getToken } from '@/utils/auth'
  import elDragDialog from '@/directive/el-dragDialog'

  export default {
    directives: {
      elDragDialog
    },
    props: {
      applyId: {
        type: String
      }
    },
    data() {
      return {
        total: null,
        multipleSelection: [],
        listLoading: true,
        searchListQuery: {
          enterpriseId: this.getEnterpriseId(),
          currentPage: 1,
          size: 10,
          title: ''
        },
        goodsList: []
      }
    },
    // 初始化页面
    created() {
    },
    filters: {
      priceFilter(e) {
        return e.toFixed(2)
      }
    },
    mounted() {
      this.token = { accessToken: getToken() }
      this.initGoodsList()
    },
    methods: {
      // 更改当前页数
      handleCurrentChange(val) {
        this.searchListQuery.currentPage = val
        this.initGoodsList()
      },
      auditStatusCilck() {
        this.initGoodsList()
      },
      // 更改当前页面大小
      handleSizeChange(val) {
        this.searchListQuery.size = val
        this.initGoodsList()
      },
      // 勾选
      handleSelectionChange(val) {
        this.multipleSelection = val
      },
      initGoodsList() {
        this.listLoading = true
        this.searchListQuery['applyId'] = this.applyId
        pageLiveRoomApplyGoods(this.searchListQuery).then(response => {
          this.total = response.data.total
          this.goodsList = response.data.records
          this.listLoading = false
        })
      },
      handleSearch() {
        this.initGoodsList()
      }
    }
  }
</script>
<style lang="less" scoped>
  .top-operate {
    margin-bottom: 0;
  }

  .search-item {
    display: flex;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: solid 1px #E4E7ED;

    > div,
    .el-cascader {
      margin-right: 10px;
    }

    .el-input {
      width: 300px;
    }
  }

  .btn-search {
    height: 60px;
    display: flex;
    align-items: center;
  }

  .user-avatar {
    width: 68px;
    height: 68px;
    display: block;
    padding: 1px;
    border: #efefef 1px solid;
  }

  .category-style {
    color: #3abbdb;
  }

  .gray-bar {
    background: #e4e4e4;
    padding: 20px;
    margin-bottom: 20px;
    width: 80%;
  }
  .tips {
    color: gray;
    font-size: 12px;
    line-height: 1.2;
    padding-top: 5px;
  }
</style>
